//
//  PlayerModel.m
//  Mahjong
//
//  Created by 饶首建 on 17/5/17.
//  Copyright © 2017年 com.ikamobile.com. All rights reserved.
//

#import "PlayerModel.h"

@implementation PlayerModel

+(instancetype)ownerInstance{
    static dispatch_once_t onceToken;
    static PlayerModel *pm;
    dispatch_once(&onceToken, ^{
        pm = [[PlayerModel alloc]init];
    });
    return pm;
}


+(instancetype)parse:(NSDictionary *)dic{
    PlayerModel *pm = [PlayerModel new];
    pm.playerId = dic[@"id"];
    if (!pm.playerId.length) {
        pm.playerId = dic[@"userid"];
    }
    pm.playerName = dic[@"name"];
    if (!pm.playerName.length) {
        pm.playerName = dic[@"nickname"];
    }
    pm.avatar = dic[@"avatar"];
    pm.isHost = [dic[@"isHost"]boolValue];
    NSString *po = dic[@"position"];
    if ([po isEqualToString:@"西"]) {
        pm.sitType = SitPositionTypeWest;
    }else if ([po isEqualToString:@"北"]) {
        pm.sitType = SitPositionTypeNorth;
    }else if ([po isEqualToString:@"南"]) {
        pm.sitType = SitPositionTypeSouth;
    }else{
        pm.sitType = SitPositionTypeEast;
    }
    return pm;
}

@end
